home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / Shutdown FX 1.3 Source / Shutdown FX ƒ / sfx wipes ƒ / Mr. Do.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-14  |  3.8 KB  |  185 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        Mr. Do.c
  4.  
  5. Purpose:    This module handles clearing the screen in a funky
  6.             manner.  See the comments below for more details.
  7.             
  8.  
  9. Shutdown FX -=- graphic effects on shutdown
  10. Copyright (C) 1993 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30.  
  31. #define        BoxSize    4
  32. #define CorrectTime 1
  33.  
  34. void MrDo(GrafPtr thePtr, Pattern *thePattern, int width, int height);
  35.  
  36. /* 25 regions, in a 5 x 5 grid.  Go around to each region in a spiral pattern
  37.    and alternatively scroll it up or down. */
  38.    
  39. void MrDo(GrafPtr thePtr, Pattern *thePattern, int width, int height)
  40. {
  41.     int            x, y;
  42.     int            vgap,hgap;
  43.     Rect        theRect, dest;
  44.     Rect        scrollsource, scrolldest;
  45.     Rect        bounds[25];
  46.     Boolean        everyOther;
  47.     
  48.     vgap=height/5;
  49.     hgap=width/5;
  50.     
  51.     for (x=0; x<25; x++)
  52.     {
  53.         switch (x)
  54.         {
  55.             case 0:
  56.             case 1:
  57.             case 2:
  58.             case 3:
  59.             case 4:
  60.                 bounds[x].top=0;
  61.                 break;
  62.             case 15:
  63.             case 16:
  64.             case 17:
  65.             case 18:
  66.             case 5:
  67.                 bounds[x].top=vgap;
  68.                 break;
  69.             case 14:
  70.             case 23:
  71.             case 24:
  72.             case 19:
  73.             case 6:
  74.                 bounds[x].top=vgap*2;
  75.                 break;
  76.             case 13:
  77.             case 22:
  78.             case 21:
  79.             case 20:
  80.             case 7:
  81.                 bounds[x].top=vgap*3;
  82.                 break;
  83.             case 12:
  84.             case 11:
  85.             case 10:
  86.             case 9:
  87.             case 8:
  88.                 bounds[x].top=vgap*4;
  89.                 break;
  90.         }
  91.         switch (x)
  92.         {
  93.             case 0:
  94.             case 15:
  95.             case 14:
  96.             case 13:
  97.             case 12:
  98.                 bounds[x].left=0;
  99.                 break;
  100.             case 1:
  101.             case 16:
  102.             case 23:
  103.             case 22:
  104.             case 11:
  105.                 bounds[x].left=hgap;
  106.                 break;
  107.             case 2:
  108.             case 17:
  109.             case 24:
  110.             case 21:
  111.             case 10:
  112.                 bounds[x].left=hgap*2;
  113.                 break;
  114.             case 3:
  115.             case 18:
  116.             case 19:
  117.             case 20:
  118.             case 9:
  119.                 bounds[x].left=hgap*3;
  120.                 break;
  121.             case 4:
  122.             case 5:
  123.             case 6:
  124.             case 7:
  125.             case 8:
  126.                 bounds[x].left=hgap*4;
  127.                 break;
  128.         }
  129.         bounds[x].left+=thePtr->portRect.left;
  130.         bounds[x].top+=thePtr->portRect.top;
  131.         bounds[x].bottom=bounds[x].top+vgap;
  132.         bounds[x].right=bounds[x].left+hgap;
  133.     }
  134.     
  135.     for (y=0; y<25; y++)
  136.     {        
  137.         if (y%2)   /* these scroll up */
  138.         {
  139.             scrollsource=bounds[y];
  140.             scrollsource.top+=BoxSize;
  141.             scrolldest=scrollsource;
  142.             OffsetRect(&scrolldest,0,-BoxSize);
  143.             
  144.             dest=bounds[y];
  145.             dest.top=dest.bottom-BoxSize;
  146.             
  147.             for (x=bounds[y].bottom-bounds[y].top-BoxSize; x>0; x-=BoxSize)
  148.             {
  149.                 StartTiming();
  150.                 CopyBits(&(thePtr->portBits), &(thePtr->portBits),
  151.                         &scrollsource, &scrolldest, 0, 0L);
  152.                 FillRect(&dest, *thePattern);
  153.  
  154.                 if (everyOther)
  155.                     TimeCorrection(CorrectTime);
  156.                 everyOther=!everyOther;
  157.             }
  158.         }
  159.         else    /* these scroll down */
  160.         {
  161.             scrollsource=bounds[y];
  162.             scrollsource.bottom-=BoxSize;
  163.             scrolldest = scrollsource;
  164.             OffsetRect(&scrolldest, 0, BoxSize);
  165.             
  166.             dest=bounds[y];
  167.             dest.bottom=dest.top+BoxSize;
  168.             
  169.             for(x = bounds[y].bottom-bounds[y].top-BoxSize; x > 0; x -= BoxSize)
  170.             {
  171.                 StartTiming();
  172.                 CopyBits(&(thePtr->portBits), &(thePtr->portBits),
  173.                         &scrollsource, &scrolldest, 0, 0L);
  174.                 FillRect(&dest, *thePattern);
  175.  
  176.                 if (everyOther)
  177.                     TimeCorrection(CorrectTime);
  178.                 everyOther=!everyOther;
  179.             }
  180.         }
  181.  
  182.         FillRect(&bounds[y], *thePattern);
  183.     }
  184. }
  185.